package com.kantboot.business.ac.controller;

import com.kantboot.business.ac.domain.ao.YrApiProductAO;
import com.kantboot.business.ac.domain.ao.YrApiProductTypeAO;
import com.kantboot.business.ac.domain.dto.YrApiToRequestDTO;
import com.kantboot.business.ac.service.IBusAcYrApiService;
import com.kantboot.util.common.result.RestResult;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/business-ac-web/yrApi")
public class BusAcYrApiController {

    @Resource
    private IBusAcYrApiService service;

    /**
     * 获取yrApi的前缀
     */
    @RequestMapping("/getYrApiPrefix")
    public RestResult<String> getYrApiPrefix(){
        return RestResult.success(service.getYrApiPrefix(),"getSuccess","获取成功");
    }

    /**
     * 生成请求参数
     */
    @RequestMapping("/generateRequestParam")
    public RestResult<String> generateRequestParam(@RequestBody Map<String,Object> map){
        return RestResult.success(service.generateRequestParam(map),"getSuccess","获取成功");
    }

    /**
     * 生成签名
     */
    @RequestMapping("/generateSign")
    public RestResult<String> generateSign(@RequestBody Map<String,Object> map){
        return RestResult.success(service.generateSign(map),"getSuccess","获取成功");
    }

    /**
     * 请求时用的参数
     */
    @RequestMapping("/generateRequestParamInRequest")
    public RestResult<String> generateRequestParamInRequest(@RequestBody Map<String,Object> map){
        return RestResult.success(service.generateRequestParamInRequest(map),"getSuccess","获取成功");
    }

    /**
     * 发送请求
     */
    @RequestMapping("/sendRequest")
    public RestResult sendRequest(@RequestBody YrApiToRequestDTO yrApiToRequest){
        return RestResult.success(service.sendRequest(yrApiToRequest),"getSuccess","获取成功");
    }

    /**
     * 获取获取产品类型和产品分类
     */
    @RequestMapping("/getProductTypeAndCategory")
    public RestResult<List<YrApiProductTypeAO>> getProductTypeAndCategory(){
        return RestResult.success(service.getProductTypeAndCategory(),"getSuccess","获取成功");
    }

    /**
     * 获取所有产品
     */
    @RequestMapping("/getAllProduct")
    public RestResult<List<YrApiProductAO>> getAllProduct(){
        return RestResult.success(service.getAllProduct(),"getSuccess","获取成功");
    }

}
